package com.itheima.d_request_04;

import jdk.internal.org.objectweb.asm.tree.analysis.Value;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;

@WebServlet("/RequestServlet07")
//http://localhost:8080/day07/RequestServlet03?username=zhangsan&password=123
public class RequestServlet07 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);


    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

       /* Map<String, String[]> map = request.getParameterMap();

        Set<Map.Entry<String, String[]>> entries = map.entrySet();
        for (Map.Entry<String, String[]> entry : entries) {
            String key = entry.getKey();
            String[] value = entry.getValue();
            for (String s : value) {
            System.out.println(key+"---"+s);

            }
        }*/

        /*Map<String, String[]> parameterMap = request.getParameterMap();

        parameterMap.forEach((key,value)->{
            System.out.println(key+"---"+Arrays.toString(value));
        });*/

        System.out.println(request.getParameter("username"));
        System.out.println(request.getParameter("password"));

        String[] hobbies = request.getParameterValues("hobby");
        System.out.println(Arrays.toString(hobbies));


    }

}